<template>
  <div>
    <!-- <el-radio-group v-model="isCollapse" style="margin-bottom: 20px;">
      <el-radio-button :label="false">展开</el-radio-button>
      <el-radio-button :label="true">收起</el-radio-button>
    </el-radio-group> -->
    <el-menu class="el-menu-vertical-demo" :collapse="isCollapse" @open="handleOpen" ref="menu" @close="handleClose"
      @select="handleSelect" :default-active="`${activeMenu}`">
      <el-menu-item v-for="(item, index) in menuList" :key="`menu_` + index" :index="`${index}`">
        <template slot="title">
          <i class="el-icon-menu" />
          <span slot="title">{{ item.title }}</span>
        </template>
      </el-menu-item>
    </el-menu>
  </div>

</template>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
</style>

<script>
export default {
  name: 'AboutView',
  props: {
    menuList: {
      type: Array,
      default: () => [],
      required: true
    },
    activeMenu: {
      type: String,
      default: '0'
    }
  },
  data() {
    return {
      isCollapse: false
    }
  },
  mounted() {
    // this.$refs.menu.close('1');
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath)
    },
    handleSelect(key, keyPath) {
      this.$refs.menu.close(keyPath[0]);
      this.$emit('select', key, keyPath)
    }
  }
}
</script>
